﻿using System;
using System.Windows.Forms;

namespace C11ScenarioLVL_Editor
{
    public partial class Form1 : Form
    {
        #region Private Fields

        private Engine.FileFormats3D.C11Undercover.C11UcLvlFile c11LvlFile;
        private OpenFileDialog ofd;
        private SaveFileDialog sfd;

        #endregion Private Fields

        #region Public Constructors

        public Form1()
        {
            InitializeComponent();
            ofd = new OpenFileDialog();
            ofd.Filter = "LVL-File (*.lvl)|*.lvl";
            this.sfd = new SaveFileDialog();
            this.sfd.Filter = this.ofd.Filter;
        }

        #endregion Public Constructors

        #region Private Methods

        private void button_Load_Click(object sender, EventArgs e)
        {
            if (this.ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                c11LvlFile = Engine.FileFormats3D.C11Undercover.C11UcLvlFile.FromFile(this.ofd.FileName);
                this.sfd.FileName = this.ofd.FileName;
            }
        }

        private void button_Save_Click(object sender, EventArgs e)
        {
            if (this.c11LvlFile != null)
            {
                c11LvlFile.PosX = 10000;
                c11LvlFile.PosY = 500;
                c11LvlFile.PosZ = 10000;

                //c11LvlFile.DirectionX = 0;
                //c11LvlFile.DirectionY = -1;
                //c11LvlFile.DirectionZ = 0;

                //c11LvlFile.value1 = 0;
                //c11LvlFile.value2 = -1;
                //c11LvlFile.value3 = 0;

                //c11LvlFile.value4 = 0;
                //c11LvlFile.value5 = -1;
                //c11LvlFile.value6 = 0;

                //  c11LvlFile.value7 = -0.78446f;
                //  c11LvlFile.value8 = 1.490f;
                // c11LvlFile.value9 = 0;

                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    this.c11LvlFile.ToFile(this.sfd.FileName);
                }
            }
            else
                MessageBox.Show("No Lvl-File loaded!");
        }

        #endregion Private Methods
    }
}